package nl.pcnerd.roelve.javagame.map;

import java.awt.image.BufferedImage;

import nl.pcnerd.roelve.javagame.Game;

public class Tile {

	private int type, x, y;
	private BufferedImage texture;
	private boolean animated;

	/**
	 * Constructor for an non animated tile
	 * 
	 * @param type
	 *            Will probably be deleted, We could use it to specify if it's a
	 *            tile for which to check collision, but we won't xD
	 * @param x
	 *            The x position of the tile on the map, from 0 to Game.HTILES
	 * @param y
	 *            The y position of the tile on the map, from 0 to Game.VTILES
	 * @param texture
	 *            The buffered image used as a texture, loaded by the resource
	 *            loader
	 */
	public Tile(int type, int x, int y, BufferedImage texture) {
		this.type = type;
		this.texture = texture;
		this.x = x;
		this.y = y;
		animated = false;
	}

	/**
	 * Constructor for an non animated tile
	 * 
	 * @param type
	 *            Will probably be deleted, We could use it to specify if it's a
	 *            tile for which to check collision, but we won't xD
	 * @param x
	 *            The x position of the tile on the map, from 0 to Game.HTILES
	 * @param y
	 *            The y position of the tile on the map, from 0 to Game.VTILES
	 * @param texture
	 *            The buffered image used as a texture, loaded by the resource
	 *            loader
	 * @param animated
	 *            Whether this tile is animated.
	 */
	public Tile(int type, int x, int y, BufferedImage texture, boolean animated) {
		this.type = type;
		this.texture = texture;
		this.x = x;
		this.y = y;
		this.animated = animated;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public BufferedImage getTexture(int xOffset, int yOffset) {
		return texture.getSubimage(xOffset * Game.TILE_SIZE, yOffset
				* Game.TILE_SIZE, Game.TILE_SIZE, Game.TILE_SIZE);
	}

	public boolean isAnimated() {
		return animated;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

}
